package edu.nf.takeoutdemo.web.admin;

import edu.nf.takeoutdemo.commons.base.BaseController;
import edu.nf.takeoutdemo.commons.result.PageResult;
import edu.nf.takeoutdemo.commons.result.Result;
import edu.nf.takeoutdemo.model.dto.OrderPageQueryDTO;
import edu.nf.takeoutdemo.model.vo.*;
import edu.nf.takeoutdemo.service.WorkSpaceService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;

/**
 *
 * @author zjl
 * @date 2025/11/4
 */
@RestController
@RequestMapping("/admin/workspace")
@Slf4j
@RequiredArgsConstructor
public class WorkSpaceController extends BaseController {

    private final WorkSpaceService workSpaceService;

    @GetMapping("/businessData")
    public Result<BusinessDataVO> businessData(){
        //获取当天的开始时间
        LocalDateTime begin = LocalDate.now().atStartOfDay();
        //获取当天的结束时间
        LocalDateTime end = LocalDate.now().atTime(LocalTime.from(LocalDateTime.MAX));
        BusinessDataVO businessDataVO  = workSpaceService.getBusinessData(begin,end);
        return success(businessDataVO);
    }

    @GetMapping("/overviewOrders")
    public Result<OrderOverViewVO> overViewOrders(){
        OrderOverViewVO orderOverViewVO =  workSpaceService.getOrderOverView();
        return success(orderOverViewVO);
    }

    @GetMapping("/overviewDishes")
    public Result<DishOverViewVO> overViewDishes(){
        DishOverViewVO dishOverViewVO =  workSpaceService.getDishOverView();
        return success(dishOverViewVO);
    }

    @GetMapping("/overviewSetmeals")
    public Result<SetmealOverViewVO> overviewSetmeals(){
        SetmealOverViewVO setmealOverViewVO =  workSpaceService.getSetmealOverView();
        return success(setmealOverViewVO);
    }

    @GetMapping("/todayOrders")
    public Result<PageResult> getTodayOrders(OrderPageQueryDTO  orderPageQueryDTO){
        PageResult pageResult =  workSpaceService.getTodayOrders(orderPageQueryDTO);
        return success(pageResult);
    }

}
